package com.jshan.blog.result;

import lombok.Getter;

@Getter
public enum ResultCodeEnum {
    SUCCESS(200, "成功"),

    FAIL(500, "失败"),
    NO_LOGIN(401, "没有登录")
    ;

    private int code;
    private String desc;

    ResultCodeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ResultCodeEnum getByCode(int valCode) {
        for (ResultCodeEnum resultEnum : ResultCodeEnum.values()) {
            if (resultEnum.code == valCode) {
                return resultEnum;
            }
        }
        return null;
    }
}
